#cmake file for test
#author:guyadong
#created:2018/05/10
cmake_minimum_required( VERSION 3.0 )
cmake_policy(SET CMP0048 NEW)
# 3.0以上版本才允许使用VERSION option
project(facelog_test VERSION 1.0.0 LANGUAGES C CXX)
#判断编译类型和版本是否满足编译要求
if(MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19)
	message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}") 
	message(STATUS "CMAKE_CXX_COMPILER_VERSION=${CMAKE_CXX_COMPILER_VERSION}" )
elseif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5)
	message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}") 
	message(STATUS "CMAKE_CXX_COMPILER_VERSION=${CMAKE_CXX_COMPILER_VERSION}" )
else()
	message(FATAL_ERROR "compiler required: Visual Studio 2015 OR gcc 5.2.0 above" )
endif()
# includes utils.cmake module
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../cmake/Modules" "${PROJECT_SOURCE_DIR}/../dependencies/cmake/Modules")
include (utils)
cxx11_support()
if(MSVC)
	#关闭C4819警告
	add_definitions("/wd4819")		
	message(STATUS "optional:/wd4819")
	#关闭CRT_SECURE警告
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
	message(STATUS "optional:-D_CRT_SECURE_NO_WARNINGS")
endif(MSVC)
if(CMAKE_COMPILER_IS_GNUCXX)
	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++" )
	set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++" )
	if(WIN32)
		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc" )
		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc" )
	endif()
endif()
##############设置目标文件生成位置#####################
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set( COMMON_SOURCE_CPP_DIR "${CMAKE_SOURCE_DIR}/../dependencies/common_source_cpp")
if( IS_DIRECTORY "${COMMON_SOURCE_CPP_DIR}" )
    # common_source_cpp.out参数用于指定外部文件夹在输出文件夹中的位置
    add_subdirectory( ${COMMON_SOURCE_CPP_DIR} common_source_cpp.out)
else()
    message(FATAL_ERROR   "INVALID FOLDER 'COMMON_SOURCE_CPP_DIR'=${COMMON_SOURCE_CPP_DIR}" )
endif()
# 如果是静态连接要设置此变量为true
#set(USE_THRIFT_STATIC true)
find_package(facelogclient REQUIRED)

set(_linke_libs gdface::facelogclient common_source)
set(_test_targets)
add_executable(connect_test connect_test.cpp )
target_link_libraries(connect_test ${_linke_libs})

#add_executable(multi_thread_test multi_thread_test.cpp ${DEPENDENT_SOURCE_DIR}/ThreadPool.cpp)
#target_link_libraries(multi_thread_test ${_linke_libs})
#list(APPEND _test_targets multi_thread_test)

add_executable(get_person_test get_person_test.cpp)
target_link_libraries(get_person_test ${_linke_libs})
list(APPEND _test_targets get_person_test)

set_target_properties(${_test_targets} PROPERTIES FOLDER "test")
set_property(TARGET ${_test_targets} APPEND PROPERTY COMPILE_OPTIONS $<$<CXX_COMPILER_ID:MSVC>:/wd4275 /wd4251>)
